/**
 * @Project : ProgrammingExercises
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q0184.java
 * @Author : WangRuoyu
 * @Date 2023/3/16 20:53
 */

package lanqiao;

/**
 * @Project : ProgrammingExercises
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q0184.java
 * @Author : WangRuoyu
 * @Date 2023/3/16 20:53
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Q0184 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        int m = Integer.parseInt(words[1]);
        int T = Integer.parseInt(words[2]);

        int[] score = new int[n + 1];
        int[] last = new int[n + 1];
        boolean[] st = new boolean[n + 1];

        int[][] order = new int[m][2];

        for (int i = 0; i < m; i++) {
            words = br.readLine().split(" ");
            order[i][0] = Integer.parseInt(words[0]);
            order[i][1] = Integer.parseInt(words[1]);
        }

        Arrays.sort(order, (o1, o2) -> o1[0] != o2[0] ? o1[0] - o2[0] : o1[1] - o2[1]);

        for (int i = 0; i < m; ) {
            int j = i;
            while (j < m && order[j][0] == order[i][0] && order[j][1] == order[i][1]) j++;
            int t = order[i][0];
            int id = order[i][1];
            int cnt = j - i;
            i = j;

            score[id] -= t - last[id] - 1;
            if (score[id] < 0) score[id] = 0;
            if (score[id] <= 3) st[id] = false;// 时间t之前的事件

            score[id] += 2 * cnt;// 时间t之后的事件
            if (score[id] > 5) st[id] = true;
            last[id] = t;
        }

        for (int i = 1; i <= n; i++) {
            if (last[i] < T) {
                score[i] -= T - last[i];
                if (score[i] <= 3) st[i] = false;
            }
        }
        int res = 0;
        for (int i = 1; i <= n; i++) {
            if (st[i]) {
                res++;
            }
        }
        System.out.println(res);
    }
}

